abstract class Shape {
  // 只有声明没有实现体, 将方法定义抽象方法, 抽象方法只能放在抽象类中
  // 抽象类不能实例化
  abstract getArea(): number;

  // 抽象类中可以包含具体实现的方法
  abc() {}
}

class Rectangle extends Shape {
  constructor(public width: number, public height: number) {
    super();
    // this.height = height;
    // this.width = width;
  }

  getArea() {
    return this.width * this.height;
  }
}

class Cirlce extends Shape {
  constructor(public r: number) {
    super();
    // this.r = r;
  }

  getArea() {
    return Math.PI * this.r ** 2;
  }
}

function getArea(shape: Shape) {
  return shape.getArea();
}

console.log(getArea(new Rectangle(2, 4)));
console.log(getArea(new Cirlce(22)));

export {};
